<?php require_once 'header.php';?>    <!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <?php echo XXF_LNAME?><br>[姓名<input type="text" name="realname" id="realname">手机<input type="text" name="mphone" id="mphone">座机<input type="text" name="zuoji" id="zuoji">职务<input type="text" name="zhiwu" id="zhiwu"> <input id="add" type="button" value="添加">]
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>姓名</th>
                                        <th>职务</th>
                                        <th>座机</th>
                                        <th>手机</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA">
                                        <td><?php echo $row['realname'];?></td>
                                        <td><?php echo $row['zhiwu'];?></td>
                                        <td><?php echo $row['zuoji'];?></td>
                                        <td><?php echo $row['mphone'];?></td>
                                        <td><a href="javascript:del(<?php echo $row['id']?>)">删除</a></td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 1, "asc" ]]
        });
        $("#add").click(function(){
            var realname=$("#realname").val();
            var mphone=$("#mphone").val();
            var zuoji=$("#zuoji").val();
            var zhiwu=$("#zhiwu").val();
			$.xconfirm("确定添加么？",function(data){
				if(data){
					$.xloading(1);
					var send=function(){
						$.post("usermanage",{type:'add',realname:realname,mphone:mphone,zuoji:zuoji,zhiwu:zhiwu},function(data1){
							if(data1==0){
								$.xloading(0);
								$.xalert("添加失败");
							}else{
								window.location.reload();
							}
						}).error(function(){send()});
					}
					send();
				}
			});
        });

    });
    function del(id){
		$.xconfirm("删除后无法恢复，确定要删除此条记录么？",function(data){
 			if(data){
				$.xloading(1);
				$.post("usermanage",{type:'del',id:id},function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("删除失败");
					}else{
						window.location.reload();
					}
				}).error(function(){del(id);}); 
			} 
		});
    }
    
    </script>